package com.biglead.demo.config;


import com.biglead.demo.interceptor.AccessLimitInterceptor;
import com.biglead.demo.interceptor.WebInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private WebInterceptor webInterceptor;

    @Autowired
    private AccessLimitInterceptor accessLimitInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(webInterceptor)
                .addPathPatterns("/goods/**")
                .addPathPatterns("/seckill/**")
                .addPathPatterns("/orders/**")
                .excludePathPatterns("/login/**");

        // 限流拦截器
        registry.addInterceptor(accessLimitInterceptor).addPathPatterns("/**");
    }
}
